<template>
    <div>
        <el-dialog title="添加库位" v-model="dialogVisible" :before-close="handleClosed">
            <el-form>
                <el-row>
                    <el-form-item label="库位编号">
                        <el-input v-model="ste.setCode" placeholder="请输入库位编号"></el-input>
                    </el-form-item>
                    <el-form-item label="库位名称">
                        <el-input v-model="ste.setName" placeholder="请输入库位名称"></el-input>
                    </el-form-item>
                    <el-form-item label="库位面积">
                        <el-input v-model="ste.setArea" placeholder="请输入库位面积"></el-input>
                    </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="库位X">
                        <el-input v-model="ste.setX" placeholder="请输入库位X"></el-input>
                    </el-form-item>
                    <el-form-item label="库位Y">
                        <el-input v-model="ste.setY" placeholder="请输入库位Y"></el-input>
                    </el-form-item>
                    <el-form-item label="库位Z">
                        <el-input v-model="ste.setZ" placeholder="请输入库位Z"></el-input>
                    </el-form-item>
                </el-row>
                <el-form-item label="库位状态">
                    <el-select v-model="ste.setStatus" placeholder="请选择库位状态">
                        <el-option label="启用" value="1"></el-option>
                        <el-option label="禁用" value="0"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="库位备注">
                    <el-input v-model="ste.setRemark" placeholder="请输入库位备注"></el-input>
                </el-form-item>
            </el-form>
            <template #footer>
                <span class="dialog-footer">
                    <el-button type="primary" @click="handleAdd">确 定</el-button>
                    <el-button @click="handleClosed">取 消</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>

<script>
import wareAreaSetAPI from "@/util/request-md/ware/ware-area-set.js";

export default {
    name: "MakeWareAreaSetDialog",
    emits: ['callClosed', 'callSaveSuccess'],
    props: ['areaId', 'visible'],
    watch: {
        'visible'(val) {
            this.dialogVisible = val;
        }
    },
    data() {
        return {
            dialogVisible: false,
            ste: {
                wareAreaId: -1,
                setCode: '',
                setName: '',
                setId: 0,
                setArea: 0,
                setRemark: '',
                setStatus: 1,
                setX: 0,
                setY: 0,
                setZ: 0
            }
        }
    },
    methods: {
        handleClosed() {
            this.$emit('callClosed');
        },
        handleAdd(){
            this.ste.wareAreaId = this.areaId;
            console.log(this.ste,">>>>>this.ste")
            console.log(this.areaId,">>>>>this.areaId")
            wareAreaSetAPI.addWareAreaSet(this.ste, (res) => {
                if(res.code === 200){
                    this.$message({
                        type: 'success',
                        message: '添加成功!'
                    });
                    this.$emit('callSaveSuccess');
                }else{
                    this.$message.error(`网络异常:${res.msg}`);
                    this.$emit('callClosed');
                }
            })
        }
    }
}
</script>

<style scoped>

</style>